function getBoundary() { // 将黑龙江省框出来
	var bdary = new BMap.Boundary();
	bdary.get("黑龙江省", function(rs) { // 获取行政区域
		var count = rs.boundaries.length; // 行政区域的点有多少个
		for (var i = 0; i < count; i++) {
			var ply = new BMap.Polygon(rs.boundaries[i], {
				strokeWeight : 2,
				strokeColor : "#ff0000",
				fillColor : "#ff0000",
				fillOpacity : 0.01
			}); // 建立多边形覆盖物
			map.addOverlay(ply); // 添加覆盖物
		}
	});
}

function displayby(loctype, type) {
	var src = "";
	if (type == "gddxyq")
		src = "instrument/dxyqalllist.ins?loctype=" + loctype;
	if (type == "gddw")
		src = "institution/dwalllist.ins?loctype=" + loctype;
	if (type == "gdxm")
		src = "project/xmalllist.ins?loctype=" + loctype;
	if (type == "gdry")
		src = "talent/ryalllist.ins?loctype=" + loctype;
	if (type == "gdsyjd")
		src = "base/syjdalllist.ins?loctype=" + loctype;
	if (type == "gdcg")
		src = "result/cgalllist.ins?loctype=" + loctype;
	if (type == "gdbcjg")
		src = "hlj/hljlayer/bcjgalllist.jsp?loctype=" + loctype;
	if (type == "gdkt")
		src = "hlj/hljlayer/ktalllist.jsp?loctype=" + loctype;
	$("#iframe").attr("src", src);
	$("#news_cont1_list").show("slow");
	return false;
}
// 显示列表框
function display(para, page) {
	var src = page + ".ins?" + para;
	$("#iframe").attr("src", src);
	$("#news_cont1_list").show("slow");
	return false;
}
// 隐藏列表框
function closeDis() {
	$("#news_cont1_list").hide("slow");
	return false;
}

// 创建http对象
function createXMLHttpRequest() {
	var request;
	try {
		// Firefox, Opera 8.0+, Safari
		request = new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
			request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("您的浏览器不支持AJAX！");
				return false;
			}
		}
	}
	return request;
}

function toggle(id, objN) { // 定义显示与隐藏层的函数
	var target = document.getElementById(id);
	var MyObj = document.getElementById(objN)
	if (target.style.display == "block") {
		target.style.display = "none";
		/* MyObj.style.display=" block"; */
		/* MyObj.innerText="显示层"; */
	} else {
		target.style.display = "block";
		/* MyObj.style.display=" none"; */
		/* MyObj.innerText='隐藏层'; */
	}
}

function pr() {
	var L = document.getElementById("left"); // 变量：L代表 id="left" 的标记
	var R = document.getElementById("right"); // 变量：R代表 id="right" 的标记
	if (L.className == "left") // 判断：如果 id="left" 的class值 等于left的话，将执行下面{}里面的内容
	{
		L.className = "left1"; // 给 id="left" 的标记 加上class：left1
		R.className = "con_right1 "; // id="right" 的标记 加上class：空格，也就是消除class
		document.getElementById('xs').src = "images/icon1.jpg"
	} else // 判断：如果 id="left" 的class值 不等于left的话，将执行下面{}里面的内容
	{
		L.className = "left"; // 给 id="left" 的标记 加上class：left
		R.className = "con_right"; // 给 id="right" 的标记 加上class：right
		document.getElementById('xs').src = "images/icon.jpg"
	}
}

function tab(mod, cursor, n) {
	for (i = 1; i <= n; i++) {
		var nav = document.getElementById(mod + i);
		var cont = document.getElementById(mod + "_" + "cont" + i);
		nav.className = (i == cursor) ? "current" : "";
		cont.style.display = (i == cursor) ? "block" : "none";
	}
}

function tabs(mod, cursor, n, type) {
	for (i = 1; i <= n; i++) {
		var nav = document.getElementById(mod + i + "_" + type);
		// var cont=document.getElementById(mod+"_"+"cont"+i+"_"+type);
		nav.className = (i == cursor) ? "current" : "";
		nav.name = (i == cursor) ? "zhibiao" : "";
		// cont.style.display=(i==cursor)?"block":"none";
	}
}

function tabs4(mod, cursor, n, type) {
	for (i = 1; i <= n; i++) {
		var nav = document.getElementById(mod + i + "_" + type);
		var cont = document.getElementById(mod + "_" + "cont" + i + "_" + type);
		nav.className = (i == cursor) ? "current" : "";
		cont.style.display = (i == cursor) ? "block" : "none";
	}
}

function tabs3(mod, cursor, n, type) {
	for (i = 1; i <= n; i++) {
		var nav = document.getElementById(mod + i + "_" + type);
		nav.className = (i == cursor) ? "current" : "";
	}
}

function tabs2(mod, cursor, n, type) {
	for (i = 1; i <= n; i++) {
		var nav = document.getElementById(mod + i + "_" + type);
		var cont = document.getElementById(mod + "_" + "cont" + i + "_" + type);
		nav.className = (i == cursor) ? "current" : "";
		cont.style.display = (i == cursor) ? "block" : "none";
	}
}

function closetb(mod, cursor, type) {
	var cont = document
			.getElementById(mod + "_" + "cont" + cursor + "_" + type);
	cont.style.display = "none";
}

function showtb(mod, cursor, type) {
	var cont = document
			.getElementById(mod + "_" + "cont" + cursor + "_" + type);
	cont.style.display = "block";
}

function getImage(shuliang, loctype, type) {
	var image = "image/red.gif";
	if (type == "hljdxyq") {
		if (loctype == "province") {
			if (shuliang > 500) {
				image = "image/red.gif";
			} else if (shuliang >= 100 && shuliang <= 500) {
				image = "image/blue.gif";
			} else if (shuliang < 100) {
				image = "image/green.gif";
			}
		} else if (loctype == "city") {
			if (shuliang > 500) {
				image = "image/red.gif";
			} else if (shuliang >= 100 && shuliang <= 500) {
				image = "image/blue.gif";
			} else if (shuliang < 100) {
				image = "image/green.gif";
			}
		} else if (loctype == "xian") {
			if (shuliang > 200) {
				image = "image/red.gif";
			} else if (shuliang >= 50 && shuliang <= 200) {
				image = "image/blue.gif";
			} else if (shuliang < 50) {
				image = "image/green.gif";
			}
		} else {
			image = "image/red.gif";
		}
	} else if (type == "hljdw") {
		if (shuliang <= 10)
			image = "image/green.gif";
		else if (shuliang <= 50)
			image = "image/blue.gif";
		else
			image = "image/red.gif";
	} else if (type == "hljxm") {
		if (shuliang <= 5)
			image = "image/green.gif";
		else if (shuliang <= 10)
			image = "image/blue.gif";
		else
			image = "image/red.gif";
	} else if (type == "gdry") {
		if (loctype == "province") {
			if (shuliang > 5000) {
				image = "image/red.gif";
			} else if (shuliang >= 500 && shuliang <= 5000) {
				image = "image/blue.gif";
			} else if (shuliang < 500) {
				image = "image/green.gif";
			}
		} else if (loctype == "city") {
			if (shuliang > 5000) {
				image = "image/red.gif";
			} else if (shuliang >= 500 && shuliang <= 5000) {
				image = "image/blue.gif";
			} else if (shuliang < 500) {
				image = "image/green.gif";
			}
		} else if (loctype == "xian") {
			if (shuliang > 1000) {
				image = "image/red.gif";
			} else if (shuliang >= 100 && shuliang <= 1000) {
				image = "image/blue.gif";
			} else if (shuliang < 100) {
				image = "image/green.gif";
			}
		} else {
			image = "image/red.gif";
		}
	} else if (type == "gdcw") {
		if (loctype == "province") {
			if (shuliang > 10000) {
				image = "image/red.gif";
			} else if (shuliang >= 5000 && shuliang <= 10000) {
				image = "image/blue.gif";
			} else if (shuliang < 5000) {
				image = "image/green.gif";
			}
		} else if (loctype == "city") {
			if (shuliang > 10000) {
				image = "image/red.gif";
			} else if (shuliang >= 5000 && shuliang <= 10000) {
				image = "image/blue.gif";
			} else if (shuliang < 5000) {
				image = "image/green.gif";
			}
		} else if (loctype == "xian") {
			if (shuliang > 5000) {
				image = "image/red.gif";
			} else if (shuliang >= 1000 && shuliang <= 5000) {
				image = "image/blue.gif";
			} else if (shuliang < 1000) {
				image = "image/green.gif";
			}
		} else {
			image = "image/red.gif";
		}
	} else if (type == "gdbcjg") {
		if (loctype == "province") {
			if (shuliang > 20) {
				image = "image/red.gif";
			} else if (shuliang >= 10 && shuliang <= 20) {
				image = "image/blue.gif";
			} else if (shuliang < 10) {
				image = "image/green.gif";
			}
		} else if (loctype == "city") {
			if (shuliang > 20) {
				image = "image/red.gif";
			} else if (shuliang >= 10 && shuliang <= 20) {
				image = "image/blue.gif";
			} else if (shuliang < 10) {
				image = "image/green.gif";
			}
		} else if (loctype == "xian") {
			if (shuliang > 10) {
				image = "image/red.gif";
			} else if (shuliang >= 5 && shuliang <= 10) {
				image = "image/blue.gif";
			} else if (shuliang < 5) {
				image = "image/green.gif";
			}
		} else {
			image = "image/red.gif";
		}
	} else if (type == "gdkt") {
		if (loctype == "province") {
			if (shuliang > 1000) {
				image = "image/red.gif";
			} else if (shuliang >= 500 && shuliang <= 1000) {
				image = "image/blue.gif";
			} else if (shuliang < 500) {
				image = "image/green.gif";
			}
		} else if (loctype == "city") {
			if (shuliang > 1000) {
				image = "image/red.gif";
			} else if (shuliang >= 500 && shuliang <= 1000) {
				image = "image/blue.gif";
			} else if (shuliang < 500) {
				image = "image/green.gif";
			}
		} else if (loctype == "xian") {
			if (shuliang > 500) {
				image = "image/red.gif";
			} else if (shuliang >= 100 && shuliang <= 500) {
				image = "image/blue.gif";
			} else if (shuliang < 100) {
				image = "image/green.gif";
			}
		} else {
			image = "image/red.gif";
		}
	} else if (type == "gdsyjd") {
		if (loctype == "province") {
			if (shuliang > 100) {
				image = "image/red.gif";
			} else if (shuliang >= 50 && shuliang <= 100) {
				image = "image/blue.gif";
			} else if (shuliang < 50) {
				image = "image/green.gif";
			}
		} else if (loctype == "city") {
			if (shuliang > 100) {
				image = "image/red.gif";
			} else if (shuliang >= 50 && shuliang <= 100) {
				image = "image/blue.gif";
			} else if (shuliang < 50) {
				image = "image/green.gif";
			}
		} else if (loctype == "xian") {
			if (shuliang > 50) {
				image = "image/red.gif";
			} else if (shuliang >= 10 && shuliang <= 50) {
				image = "image/blue.gif";
			} else if (shuliang < 10) {
				image = "image/green.gif";
			}
		} else {
			image = "image/red.gif";
		}
	} else if (type == "gdcg") {
		if (loctype == "province") {
			if (shuliang > 40) {
				image = "image/red.gif";
			} else if (shuliang >= 20 && shuliang <= 40) {
				image = "image/blue.gif";
			} else if (shuliang < 20) {
				image = "image/green.gif";
			}
		} else if (loctype == "city") {
			if (shuliang > 40) {
				image = "image/red.gif";
			} else if (shuliang >= 20 && shuliang <= 40) {
				image = "image/blue.gif";
			} else if (shuliang < 20) {
				image = "image/green.gif";
			}
		} else if (loctype == "xian") {
			if (shuliang > 20) {
				image = "image/red.gif";
			} else if (shuliang >= 10 && shuliang <= 20) {
				image = "image/blue.gif";
			} else if (shuliang < 10) {
				image = "image/green.gif";
			}
		} else {
			image = "image/red.gif";
		}
	}
	return image;
}

var hightlight = -1;
var oInputField; // 考虑到很多函数中都要使用
var oPopDiv; // 因此采用全局变量的形式
var oconUl;

// 初始化变量
function initVars(id, popup, con_ul) {
	oInputField = $("#" + id);
	oPopDiv = $("#" + popup);
	oconUl = $("#" + con_ul);
}

// 清除提示内容
function clearcon() {
	if (oconUl != null)
		oconUl.empty();
	if (oPopDiv != null)
		oPopDiv.removeClass("show");
}

/*
 * 显示自动补全的下拉框
 */
function setcon(the_con) {
	clearcon();

	oPopDiv.addClass("show");
	var reg = /[\",\[,\]]/g;
	for (var i = 0; i < the_con.length; i++) {
		// 将匹配的提示结果逐一显示给用户,高亮显示查询词
		var hl = oInputField.val().toUpperCase();
		the_con[i] = the_con[i].replace(hl,
				"<font style='font-weight:bold' color='red'>" + hl + "</font>");
		oconUl.append($("<li>" + the_con[i].replace(reg, "") + "</li>"));
		oconUl.find("li").click(function() {
			oInputField.val($(this).text());
			clearcon();
		}).hover(function() {
			$(this).addClass("mouseOver");
		}, function() {
			$(this).removeClass("mouseOver");
		});
	}
}

function findcon(id, popup, con_ul) {
	initVars(id, popup, con_ul); // 初始化变量
	var c = isChinese(oInputField.val());
	var myEvent = window.event;
	var keycode = myEvent.keyCode; // 获取键盘键值(keycode >= 65 && keycode <= 90) ||
	// keycode==8 || keycode == 46 ||
	if (keycode == 38 || keycode == 40) { // 如果输入的是向上向下
		if (keycode == 38) {
			// 向上
			var autoNodes = oconUl.find("li");
			if (hightlight != -1) {
				// 把高亮节点恢复
				autoNodes.eq(hightlight).removeClass("mouseOver");
				hightlight--;
			} else {
				hightlight = autoNodes.length - 1;
			}
			if (hightlight == -1) {
				// 如果到顶 把高亮移动到最后
				hightlight = autoNodes.length - 1;
			}
			;
			autoNodes.eq(hightlight).addClass("mouseOver");
			// 把值放入文本框中
			var context = oconUl.find("li").eq(hightlight).text();
			oInputField.val(context);
		}

		if (keycode == 40) {
			// 向下
			var autoNodes = oconUl.find("li");
			if (hightlight != -1) {
				// 把高亮节点恢复
				autoNodes.eq(hightlight).removeClass("mouseOver");
			}
			hightlight++;
			if (hightlight == autoNodes.length) {
				// 如果到顶 把高亮移动到最后
				hightlight = 0;
			}
			autoNodes.eq(hightlight).addClass("mouseOver");
			// 把值放入文本框中
			var context = oconUl.find("li").eq(hightlight).text();
			oInputField.val(context);
		}
	} else if (keycode == 13) {
		// 如果输入的是回车
		if (hightlight != -1) {
			// 取出节点的内容
			var context = oconUl.find("li").eq(hightlight).text();
			clearcon();
			hightlight = -1;
			oInputField.val(context);
		}
	} else if (c) {
		if (oInputField.val().replace(/(^\s*)|(\s*$)/g, '') == "") {
			clearcon();
			return;
		} // 值为空，退出
		if (jQuery.trim(oInputField.val()).length > 0) {
			// 获取异步数据
			// $.post('user_testAjax.action',{dirName:oInputField.val()},function(data){
			$.post('cxbq/query.ins', {
				dirName : oInputField.val(),
				idName : id,
				Type : "cn"
			}, function(data) {
				var aResult = new Array();
				if (data.length > 0) {
					aResult = data.split(",");
					setcon(aResult); // 显示服务器结果
				} else {
					clearcon();
				}
			});
		} else {
			clearcon(); // 无输入时清除提示框（例如用户按del键）
			hightlight = -1
		}
	} else if ((keycode >= 65 && keycode <= 90) || keycode == 8
			|| keycode == 46) {
		if (oInputField.val().replace(/(^\s*)|(\s*$)/g, '') == "") {
			clearcon();
			return;
		} // 值为空，退出
		if (jQuery.trim(oInputField.val()).length > 0) {
			// 获取异步数据
			// $.post('user_testAjax.action',{dirName:oInputField.val()},function(data){
			$.post('cxbq/query.ins', {
				dirName : oInputField.val(),
				idName : id,
				Type : "py"
			}, function(data) {
				var aResult = new Array();
				if (data.length > 0) {
					aResult = data.split(",");
					setcon(aResult); // 显示服务器结果
				} else {
					clearcon();
				}
			});
		} else {
			clearcon(); // 无输入时清除提示框（例如用户按del键）
			hightlight = -1
		}
	}
}

/*
 * 判断输入是否为中文词
 */
function isChinese(temp) {
	var re = /[^\u4e00-\u9fa5]/;
	if (re.test(temp))
		return false;
	return true;
}

/*
 * 打印当前页中iframe中的内容,后期需要考虑打印分页的情况
 */
function printiframe() {
	var newW = document.getElementsByTagName('iframe')[0].contentWindow;
	var url = newW.location.href;
	var pos = url.indexOf("_fenye");
	if (pos > 0) {
		url = url.replace("_fenye", "");
		var win = window.open(url);
		win.print();
		return false;
	}
	newW.print();
	return false;
}